/**
 * Copyright (c) 2017-2017 All Rights Reserved.
 */
package com.zbest.zpay.exchange.biz.action.pay;

import java.math.BigDecimal;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zbest.common.lang.enums.BizCode;
import com.zbest.common.lang.exception.ZpayException;
import com.zbest.zpay.exchange.dal.dao.FluxInfoDAO;
import com.zbest.zpay.exchange.dal.model.FluxInfoDO;
import com.zbest.zpay.service.exchange.model.FluxKeyEnum;
import com.zbest.zpay.shared.process.BaseAction;
import com.zbest.zpay.shared.process.ProcessResult;

/**
 * 
 *
 * @author Administrator
 * @version $Id: CheckFinAccountPayInfoAction.java, v 0.1 2017-5-14 下午11:26:55 Administrator Exp $
 */
@Service("checkFinCardPayInfoAction")
public class CheckFinCardPayInfoAction extends BaseAction {

    @Resource
    private FluxInfoDAO fluxInfoDAO;

    /** 
     * @see com.zbest.zpay.shared.process.BaseAction#perform(com.zbest.zpay.shared.process.ProcessResult)
     */
    @Override
    public void perform(ProcessResult processResponse) {

        String instSerialNo = getValue(FluxKeyEnum.INST_SERIAL_NO.getCode());
        String channelId = getValue(FluxKeyEnum.CHANNEL_ID.getCode());

        FluxInfoDO fluxInfoDO = fluxInfoDAO.queryBySerialNo(instSerialNo, channelId);
        BigDecimal amount = getValue(FluxKeyEnum.AMOUNT.getCode());
        if (fluxInfoDO.getAmount().compareTo(amount) != 0) {
            throw new ZpayException(BizCode.MONEY_NOT_EQUAL);
        }

        setValue(FluxKeyEnum.FLUX_INFO_DO.getCode(), fluxInfoDO);
    }

}
